We are migrating the bug tracker to github Issues. This is now the preferred way to report NASM bugs.

Self-registration is disabled due to spam issue (mail gorcunov@gmail.com or hpa@zytor.com to create an account)

Bug 3392858 - Nested nonrecursive use of the same smacro not allowed
Summary: Nested nonrecursive use of the same smacro not allowed
Status: OPEN
Alias: None
Product: NASM
Classification: Unclassified
Component: Assembler (show other bugs)
Version: 2.16.xx
Hardware: All All
: Medium normal
Assignee: nobody
URL:
Depends on:
Blocks:
 
Reported: 2023-04-20 02:44 PDT by E. C. Masloch
Modified: 2023-04-20 02:44 PDT (History)
4 users (show)

Obtained from: Built from git using configure
Generated by: ---
Bug category:
Observed for: ---
Regression: ---
Regression since:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description E. C. Masloch 2023-04-20 02:44:13 PDT
I tried to create an expression in which I used my words(...) macro twice, one nested in the other. This didn't work but it took me a while to understand why. It appears that the preprocessor doesn't expand the inner use of the smacro. I assume this is intended to avoid recursion, however my use is not recursive.

$ nasm -v
NASM version 2.16rc0 compiled on Sep  6 2022
$ cat test.asm
; %include "lmacros1.mac"

                ; Compute required words/dwords/qwords/paragraphs/pages/KiB of known byte size (rounds up if necessary)
%idefine bytes(b)       (b)
%idefine words(b)       ((b)+1>>1)
%idefine dwords(b)      ((b)+3>>2)
%idefine qwords(b)      ((b)+7>>3)
%idefine paragraphs(b)  ((b)+15>>4)
%idefine paras(b)       ((b)+15>>4)
%idefine pages(b)       ((b)+511>>9)
%idefine kib(b)         ((b)+1023>>10)

                ; Compute required bytes of known word/dword/qword/paragraph/page/KiB size
%idefine frombytes(b)           (b)
%idefine fromwords(w)           ((w)<<1)
%idefine fromdwords(d)          ((d)<<2)
%idefine fromqwords(q)          ((q)<<3)
%idefine fromparagraphs(p)      ((p)<<4)
%idefine fromparas(p)           ((p)<<4)
%idefine frompages(p)           ((p)<<9)
%idefine fromkib(k)             ((k)<<10)

        db fromparas(paras(1))
        db fromwords(words(1))
        db words(fromwords(words(1)))

$ nasm test.asm
test.asm:25: error: expecting `)'
$ nasm test.asm -E | tail -n5
%line 23+1 test.asm
 db ((((1)+15>>4))<<4)
 db ((((1)+1>>1))<<1)
 db ((((words(1))<<1))+1>>1)

$